package com.wgtgt.factorization;

import java.util.ArrayList;
import java.util.List;

/**
 * Hello world!
 *
 */
public class Main {
	public static void main(String[] args) {
		for (int i = 950; i < 1050; i++) {
			if (isPrime(i)) {
				System.out.println(i);
			} else {
				System.out.println(factorization(i));
			}
		}
	}

	private static String factorization(int num) {
		List<Integer> list = new ArrayList<Integer>();
		while (true) {
			if (isPrime(num)) {
				break;
			}
			for (int i = 2; i < num; i++) {
				if (num % i == 0) {
					list.add(i);
					num = num / i;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(num);
		sb.append(" = ");
		for (int i = 0; i < list.size() - 1; i++) {
			sb.append(list.get(i));
			sb.append(" * ");
		}
		sb.append(list.get(list.size() - 1));
		return sb.toString();
	}

	private static boolean isPrime(int num) {
		for (int i = 2; i < num; i++) {
			if (num % i == 0) {
				return false;
			}
		}
		return true;
	}
}
